package com.nwpu.coursesupport.controller;

import com.nwpu.coursesupport.entity.ForumPostReply;
import com.nwpu.coursesupport.mapper.ForumPostReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ForumPostController extends AbstractController{

	@Autowired
	private ForumPostReplyMapper forumPostReplyMapper;

	@RequestMapping("/forumPost")
	public String list(@RequestParam("postId")Integer postId, Model model){
		List<ForumPostReply> forumPostReplies = forumPostReplyMapper.selectByExample(null);//

		model.addAttribute("forumPostReplies",forumPostReplies);
		return "/teapage/forum-post";
	}
	@RequestMapping("/createPostReply")
	public String createModule(ForumPostReply ForumPostReply){
		forumPostReplyMapper.insert(ForumPostReply);
		return "redirect:/forumPost";
	}

}
